<!DOCTYPE html>
<html>

<head>
    <link href="./js/nouislider/nouislider.min.css" rel="stylesheet">
    <script src="./js/nouislider/nouislider.js"></script>
    <style>
        #showcase {
            margin: 0 20px;
            text-align: center;
        }

        #slider {
            height: 18px;
            width: 600px;
            margin: 0 auto 30px;
        }

        #value-span,
        #value-input {
            width: 50%;
            float: left;
            display: block;
            text-align: center;
            margin: 0;
        }

        .noUi-draggable {
            cursor: default;
        }
    </style>
</head>

<body>
    <div id="slider"></div>
</body>
<script>
    var slider = document.getElementById('slider');
    noUiSlider.create(slider, {
        start: [40, 60],
        behaviour: 'drag',
        connect: true,
        range: {
            'min': 0,
            'max': 100
        }
    });

    // 监听范围变化
    slider.noUiSlider.on('update', function (values, handle) {
        // values 是一个数组，包含当前滑块的范围
        console.log('范围: ' + values.join(' - '));
    });

    setTimeout(function () {
        console.log('setTimeout');
        slider.noUiSlider.set([0,30]);
        // 使用 updateOptions 方法动态更改范围
        /*
        slider.noUiSlider.updateOptions({
            range: {
                'min': 0,
                'max': 100
            }
        });
        */
    }, 3000);

    console.log('slider.noUiSlider', slider.noUiSlider);
</script>

</html>